package com.user.service.send.service.controller;



import com.user.service.receive.api.UserServiceApi;
import com.user.service.receive.dto.CommonResult;
import com.user.service.receive.dto.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by macro on 2019/8/29.
 */
@RestController
@RequestMapping("/user")
public class UserFeignController {
    @Autowired
    private UserServiceApi userServiceApi;

    /**
     * http://127.0.0.1:8701/user/1
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public CommonResult getUser(@PathVariable Long id) {
        String property = System.getProperty("${httpurl1}");
        System.out.println(property);
        return userServiceApi.getUser(id);
    }

    @GetMapping("/getByUsername")
    public CommonResult getByUsername(@RequestParam String username) {
        return userServiceApi.getByUsername(username);
    }

    @PostMapping("/create")
    public CommonResult create(@RequestBody User user) {
        return userServiceApi.create(user);
    }

    @PostMapping("/update")
    public CommonResult update(@RequestBody User user) {
        return userServiceApi.update(user);
    }

    @PostMapping("/delete/{id}")
    public CommonResult delete(@PathVariable Long id) {
        return userServiceApi.delete(id);
    }
}
